
package coop.bancocredicoop.proyectos.gd.alfresco

import coop.bancocredicoop.proyectos.gd.alfresco.AlfrescoHttpClient

class AlfrescoHttpClientWithAlfTicket extends AlfrescoHttpClient {

    def ticket

    AlfrescoHttpClientWithAlfTicket(alfrescoConfig, ticket) {
        super(alfrescoConfig)
        this.ticket = ticket
    }

    private def getTicketParam(relativeURL) {
        if (relativeURL.startsWith(alfrescoConfig.serviceURL)) {
            "alf_ticket"
        } else {
            "ticket"
        }
    }

    def getUrl(relativeURL) {
        def url = super.getUrl(relativeURL)       
        url.setParameter(getTicketParam(relativeURL), ticket)
    }
   
}


